//
//  ViewController.m
//  WTLiveSDKDemo
//
//  Created by ben on 16/9/26.
//  Copyright © 2016年 ben. All rights reserved.
//

#import "ViewController.h"
#import "WTPersonInfoManager.h"



//#import "WTGiftService.h"
//#import "WTLiveRoomInfoService.h"
#import "WTFocusService.h"
#import "WTUserInfoService.h"
//#import "WTGetCoinService.h"
//#import "WTMainCategoryService.h"
//
//#import "WTSystemCategoryService.h"
//#import "WTCustomCategoryService.h"
//
//#import "WTLiveCreateService.h"

#import "WTLiveHelper.h"
#import "WTLiveViewController.h"

@interface ViewController ()

//
//@property (nonatomic,strong) WTGiftService* giftService;
//@property (nonatomic,strong) WTLiveRoomInfoService* liveRoomInfoService;
@property (nonatomic,strong) WTFocusService*        focusService;
@property (nonatomic,strong) WTUserInfoService*     userInfoService;
//@property (nonatomic,strong) WTGetCoinService*      getCoinService;
//@property (nonatomic,strong) WTMainCategoryService* mainCategoryService;
//
//@property (nonatomic,strong) WTSystemCategoryService*   systemCategoryService;
//@property (nonatomic,strong) WTCustomCategoryService*   customCategoryService;
//
//@property (nonatomic,strong) WTLiveCreateService*       liveCreateService;
@end

@implementation ViewController

- (IBAction)startLive:(id)sender {
//
    [WTLiveHelper requestLiveAccess:^(BOOL granted) {
        if (granted) {
            WTLiveViewController* ctler = [[WTLiveViewController alloc] init];
            [self presentViewController:ctler animated:YES completion:nil];
        }
    }];
    
}

- (IBAction)startWatch:(id)sender {
    
//    WTBroadCastViewController* ctler = [[WTBroadCastViewController alloc] init];
//    [self presentViewController:ctler animated:YES completion:nil];
}


- (void)viewDidLoad {
    [super viewDidLoad];

    WTConfig.desKey = @"6zM66WyY";
    
   ;

    //开直播
    WTConfig.session_token = @"1d5808e8cc05218077d8fb4542e2de90";
    WTConfig.net_accid = @"330149a5316ca7d8cefcab59f9eedac4";
    WTConfig.net_token = @"1c0dd9f65f64cbce486de30b1bb2d6fe";
    
    [[WTPersonInfoManager sharedManager] fetchPersonInfo:^(BOOL sucess) {
        
    }];
//    [[WTPersonInfoManager sharedManager] fetchPersonInfo:^{
//        
//    }];
    
    //看直播
//    WTConfig.session_token = @"aeab16144a3e3e051baeec651a9c9258";
//    WTConfig.net_accid = @"467e3d0d17026b748a144bbe35db6f9d";
//    WTConfig.net_token = @"d18757bf42b053f32a6bb9b171f6560c";
//    [[WTPersonInfoManager sharedManager] fetchPersonInfo:^{
//        
//    }];


    
//    WTConfig.nick = @"hello";
//    WTConfig.level = 14;
//    WTConfig.avatar = @"http://66tv.oss-cn-beijing.aliyuncs.com/upload/client/ios/15611111111/avatar/15611111111.png";
//    WTConfig.user_id = @"15611111111";
//    WTConfig.cuteCode = @"661003866";
    
//    WTConfig.nick = @"贲知鹏";
//    WTConfig.level = 36;
//    WTConfig.avatar = @"http://66tv.oss-cn-beijing.aliyuncs.com/upload/client/ios/15651017277/avatar/15651017277.png";
//    WTConfig.user_id = @"15651017277";
//    
//    WTConfig.session_token = @"aeab16144a3e3e051baeec651a9c9258";
//    WTConfig.net_accid = @"467e3d0d17026b748a144bbe35db6f9d";
//    WTConfig.net_token = @"d18757bf42b053f32a6bb9b171f6560c";
//    WTConfig.cuteCode = @"661003366";
////
    [[WTLiveSDK shareSDK] registerWithAppID:@"7cc57d475305f3f3831c53698ce898ec" cerName:@"66TV"];

    
    if(![[WTLiveSDK shareSDK].loginManager isLogin]){
        
        [[WTLiveSDK shareSDK].loginManager login:^{
            NSLog(@"登录成功");
        } failure:^(NSError *error) {
            
        }];
    }
    
//    [self.giftService start:@{@"session_token":WTConfig.session_token} completionHandler:^(id responseObject, NSError *error) {
//        
//    }];
//    
//    [self.liveRoomInfoService start:@{@"session_token":WTConfig.session_token,@"anchor_id":@(15651017277)} completionHandler:^(id responseObject, NSError *error) {
//        
//    }];
//    
//    [self.focusService start:@{@"session_token":WTConfig.session_token,@"anchor_id":@(13911111111),@"is_focus":@[@(1),@(1)]} completionHandler:^(id responseObject, NSError *error) {
//        
//        NSLog(@"dsfds");
//    }];
////
//    [self.userInfoService start:@{@"net_ease_or_user_id":@"15651017277"} completionHandler:^(id responseObject, NSError *error) {
//        
//        NSLog(@"sdf");
//    }];
//
//    [self.getCoinService start:@{@"session_token":WTConfig.session_token} completionHandler:^(id responseObject, NSError *error) {
//        
//    }];
//    
//    [self.mainCategoryService start:@{@"session_token":WTConfig.session_token} completionHandler:^(id responseObject, NSError *error) {
//        
//    }];
//    
//    [self.systemCategoryService start:@{@"session_token":WTConfig.session_token,@"assort_id":@(1)} completionHandler:^(id responseObject, NSError *error) {
//        
//    }];
//    
//    [self.customCategoryService start:@{@"session_token":WTConfig.session_token,@"assort_id":@(1),@"num":@(20)} completionHandler:^(id responseObject, NSError *error) {
//        
//    }];
//    
//
//    [self.liveCreateService start:@{@"assort_id":@(1),@"session_token":WTConfig.session_token} completionHandler:^(id responseObject, NSError *error) {
//        
//        /*
//         NSMutableDictionary* params = [[NSMutableDictionary alloc] initWithDictionary:@{@"assort_id":@(assort_id),@"session_token":[WTUserInfoModel userSession_token]}];
//         if(sl_assort_info){
//         [params setObject:sl_assort_info forKey:@"sl_assort_info"];
//         }
//         if(labels){
//         [params setObject:labels forKey:@"labels"];
//         }
//         if(location){
//         [params setObject:location forKey:@"location"];
//         }
//         if(des){
//         des = [des stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
//         if(des.length > 0){
//         [params setObject:des forKey:@"description"];
//         }
//         }
//         */
//    }];
  
 
    
//    [WTGiftService start:@{} serviceType:ServiceType_Gift completionHandler:^(id responseObject, NSError *error) {
//        
//    }];
    
    // Do any additional setup after loading the view, typically from a nib.
//    self.dataSource = [NSMutableArray arrayWithCapacity:0];
//    
//    [[WTLiveSDK shareSDK].chatManager addChatMessagesReceivedCallBackBlock:^(NSArray<WTBaseMessageModel *> *messageModels) {
//
//        
//        if(messageModels.count <= 0){
//            return;
//        }
//        for (WTBaseMessageModel* model in messageModels) {
//            
//            if(model.sessionType == NIMSessionTypeP2P){
//                WTChatMessageModel* chatMessageModel = (WTChatMessageModel*)model;
//                [self.dataSource addObject:chatMessageModel.chat_message_text];
//                
//            }
//        }
//        [self.chatListTableView reloadData];
//        [self.chatListTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:self.dataSource.count - 1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
//
//    }];
//    
//    
//    dispatch_async(dispatch_get_global_queue(0, 0), ^{
//        for(NSInteger i = 0; i < 30001; i++){
//            
//            NSLog(@"我是1");
//            [[WTLiveSDK shareSDK].chatManager sendChatMessage:[NSString stringWithFormat:@"%zd",i+1] sessionID:@""];
//        }
//    });
//    
////    dispatch_async(dispatch_get_global_queue(0, 0), ^{
////        for(NSInteger i = 0; i < 10000; i++){
////            
////            NSLog(@"我是2");
////            [[WTLiveSDK shareSDK].chatManager sendChatMessage:[NSString stringWithFormat:@"%zd",i+1] sessionID:@""];
////        }
////    });
}

//- (WTGiftService *)giftService{
//    if(!_giftService){
//        _giftService = [[WTGiftService alloc] init];
//    }
//    return _giftService;
//}
//
//- (WTLiveRoomInfoService *)liveRoomInfoService{
//    if(!_liveRoomInfoService){
//        _liveRoomInfoService = [[WTLiveRoomInfoService alloc] init];
//    }
//    return _liveRoomInfoService;
//}
//
- (WTFocusService *)focusService{
    if(!_focusService){
        _focusService = [[WTFocusService alloc] init];
    }
    return _focusService;
}
//
- (WTUserInfoService *)userInfoService{
    if(!_userInfoService){
        _userInfoService = [[WTUserInfoService alloc] init];
    }
    return _userInfoService;
}
//
//- (WTGetCoinService *)getCoinService{
//    if(!_getCoinService){
//        _getCoinService = [[WTGetCoinService alloc] init];
//    }
//    return _getCoinService;
//}
//
//- (WTMainCategoryService *)mainCategoryService{
//    if(!_mainCategoryService){
//        _mainCategoryService = [[WTMainCategoryService alloc] init];
//    }
//    return _mainCategoryService;
//}
//
//- (WTSystemCategoryService *)systemCategoryService{
//    if(!_systemCategoryService){
//        _systemCategoryService = [[WTSystemCategoryService alloc] init];
//    }
//    return _systemCategoryService;
//}
//
//- (WTCustomCategoryService *)customCategoryService{
//    if(!_customCategoryService){
//        _customCategoryService = [[WTCustomCategoryService alloc] init];
//    }
//    return _customCategoryService;
//}
//
//- (WTLiveCreateService *)liveCreateService{
//    if(!_liveCreateService){
//        _liveCreateService = [[WTLiveCreateService alloc] init];
//    }
//    return _liveCreateService;
//}
//
@end
